﻿using ChongJu.ModelManager.Login;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;

namespace ChoJu.Converters.Main
{
    public class ViewByUserConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            UserModel user = (UserModel)value;
            if (user == null)
                return Visibility.Collapsed;
            if(parameter?.ToString().StartsWith("!") == true)
            {
                if (parameter?.ToString().ToLower().Contains(user.UserType.ToString().ToLower()) == true)
                    return Visibility.Collapsed;
                else
                    return Visibility.Visible;
            }
            else
            {
                if (parameter?.ToString().ToLower().Contains(user.UserType.ToString().ToLower()) == true)
                    return Visibility.Visible;
                else
                    return Visibility.Collapsed;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
